<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>${systemName}</title>
    <meta name="description" content="${systemName}">
    <meta name="author" content="stylefeng">

    <link rel="stylesheet" href="${ctxPath}/assets/common/layui/css/layui.css"/>
    <link href="${ctxPath}/assets/expand/plugins/ztree/zTreeStyle.css" rel="stylesheet" type="text/css"/>
    <style type="text/css">
        #upload{
            margin-top: 20px;
            margin-bottom: 20px;
        }
    </style>
</head>

<body>
<div class="layui-container">
    <blockquote class="layui-elem-quote">${data.dataName}</blockquote>
    <div class="layui-upload-drag" id="upload">
        <i class="layui-icon"></i>
        <p>点击上传，或将文件拖拽到此处系统会自动上传</p>
        <div  id="uploadDemoView">
            @if(files!=null){
            <hr>
            <p>已上传：${files.fileName}</p>
            @}
        </div>
    </div>

</div>

@/* 加入contextPath属性和session超时的配置 */
<script type="text/javascript">
    var Feng = {
        ctxPath: "",
        addCtx: function (ctx) {
            if (this.ctxPath === "") {
                this.ctxPath = ctx;
            }
        }
    };
    Feng.addCtx("${ctxPath}");
</script>
<script type="text/javascript" src="${ctxPath}/assets/common/layui/layui.js"></script>
<script type="text/javascript" src="${ctxPath}/assets/common/js/common.js"></script>

<!--其他插件js-->
<script type="text/javascript" src="${ctxPath}/assets/expand/plugins/jquery/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="${ctxPath}/assets/expand/plugins/ztree/jquery.ztree.all.min.js"></script>


<script>
    layui.use(['ax','admin','form','upload'], function () {
        var $ = layui.$;
        var $ax = layui.ax;
        var admin = layui.admin;
        var form = layui.form;
        var upload = layui.upload;

        // 让当前iframe弹层高度适应
        admin.iframeAuto();

        //根据dataType定义允许上传的类型
        var dataType = "${data.dataType}";
        var types = {
            "excel":"xls|xlsx",
            "word":"doc|docx",
            "pdf":"pdf",
            "img":"jpg|png|bmp"
        }

        //拖拽上传
        upload.render({
            elem: '#upload'
            ,url: Feng.ctxPath + '/deal/upload' //改成您自己的上传接口
            ,accept: 'file' //普通文件
            ,exts: types[dataType]
            ,data:{"dataId":"${data.dataId}"}
            ,done: function(res){
                if(res.code==0){
                    Feng.success("上传成功！");
                    //传给上个页面，刷新table用
                    admin.putTempData('formOk', true);
                    //关掉对话框
                    admin.closeThisDialog();
                }else{
                    Feng.error(res.msg)
                }
            }
        });


        form.on("submit(btnSubmit)",function (data) {
            var ajax = new $ax(Feng.ctxPath + "/deal/import", function (data) {
                Feng.success("复制成功，请选择目标年度查看！");

                //传给上个页面，刷新table用
                admin.putTempData('formOk', true);

                //关掉对话框
                admin.closeThisDialog();
            }, function (data) {
                Feng.error("复制失败！" + data.responseJSON.message)
            });
            ajax.set(data.field);
            ajax.start();
        })
    })
</script>

</body>

</html>

